import config from "@/config"
import http from "@/utils/request"


// 客户
export default {
  // 客户管理
  getCustomers: {
    url: `${config.API_URL}/customer/list`,
    name: "获取客户列表",
    get: function (param) {
      return new Promise((resolve, reject) => {
        http.get(this.url, param).then((response) => {
          resolve(response)
        }).catch((error) => {
          resolve(error.data)
        })
      })
    }
  },
  addCustomer: {
    url: `${config.API_URL}/customer/add`,
    name: "添加客户",
    post: function (data) {
      return new Promise((resolve, reject) => {
        http.post(this.url, data).then((response) => {
          resolve(response)
        }).catch((error) => {
          resolve(error.data)
        })
      })
    }
  },
  editCustomer: {
    url: `${config.API_URL}/customer/update`,
    name: "更新客户",
    post: function (data) {
      return new Promise((resolve, reject) => {
        http.post(this.url, data).then((response) => {
          resolve(response)
        }).catch((error) => {
          resolve(error.data)
        })
      })
    }
  },
  deleteCustomer: {
    url: `${config.API_URL}/customer/delete`,
    name: "删除客户",
    post: function (data) {
      return new Promise((resolve, reject) => {
        http.postParam(this.url, data).then((response) => {
          resolve(response)
        }).catch((error) => {
          resolve(error.data)
        })
      })
    }
  },
  submitAudit: {
    url: `${config.API_URL}/customer/commitAudit`,
    name: "提交客户审核",
    post: function (data) {
      return new Promise((resolve, reject) => {
        http.postParam(this.url, data).then((response) => {
          resolve(response)
        }).catch((error) => {
          resolve(error.data)
        })
      })
    }
  },

  checkCustomer: {
    url: `${config.API_URL}/customer/audit`,
    name: "审核客户",
    post: function (data) {
      return new Promise((resolve, reject) => {
        http.postParam(this.url, data).then((response) => {
          resolve(response)
        }).catch((error) => {
          resolve(error.data)
        })
      })
    }
  },

  getCustomerById: {
    url: `${config.API_URL}/customer/listId`,
    name: "跟进id获取客户详情",
    get: function (data) {
      return new Promise((resolve, reject) => {
        http.get(this.url, data).then((response) => {
          resolve(response)
        }).catch((error) => {
          resolve(error.data)
        })
      })
    }
  },

  assignCustomer: {
    url: `${config.API_URL}/customer/allocation`,
    name: "分配客户",
    post: function (data) {
      return new Promise((resolve, reject) => {
        http.postParam(this.url, data).then((response) => {
          resolve(response)
        }).catch((error) => {
          resolve(error.data)
        })
      })
    }
  },
  unbindCustomer: {
    url: `${config.API_URL}/customer/division`,
    name: "解绑客户",
    post: function (data) {
      return new Promise((resolve, reject) => {
        http.postParam(this.url, data).then((response) => {
          resolve(response)
        }).catch((error) => {
          resolve(error.data)
        })
      })
    }
  },

  searchCustomer: {
    url: `${config.API_URL}/customer/distinct`,
    name: "搜索客户 是否已存在",
    post: function (data) {
      return new Promise((resolve, reject) => {
        http.postParam(this.url, data).then((response) => {
          resolve(response)
        }).catch((error) => {
          resolve(error.data)
        })
      })
    }
  },

  upgrade: {
    url: `${config.API_URL}/customer/upgrade`,
    name: "升级成月结客户",
    post: function (data) {
      return new Promise((resolve, reject) => {
        http.postParam(this.url, data).then((response) => {
          resolve(response)
        }).catch((error) => {
          resolve(error.data)
        })
      })
    }
  },



  // 客户联系记录管理
  recordList: {
    getRecordList: {
      url: `${config.API_URL}/accountrecordss/list`,
      name: "获取客户联系记录列表",
      get: function (param) {
        return new Promise((resolve, reject) => {
          http.get(this.url, param).then((response) => {
            resolve(response)
          }).catch((error) => {
            resolve(error.data)
          })
        })
      }
    },

    addRecord: {
      url: `${config.API_URL}/accountrecordss/add`,
      name: "添加客户联系记录",
      post: function (data) {
        return new Promise((resolve, reject) => {
          http.post(this.url, data).then((response) => {
            resolve(response)
          }).catch((error) => {
            resolve(error.data)
          })
        })
      }
    },

    updateRecord: {
      url: `${config.API_URL}/accountrecordss/update`,
      name: "修改客户联系记录",
      post: function (data) {
        return new Promise((resolve, reject) => {
          http.post(this.url, data).then((response) => {
            resolve(response)
          }).catch((error) => {
            resolve(error.data)
          })
        })
      }
    },

    deleteRecord: {
      url: `${config.API_URL}/accountrecordss/delete`,
      name: "删除客户联系记录",
      post: function (data) {
        return new Promise((resolve, reject) => {
          http.postParam(this.url, data).then((response) => {
            resolve(response)
          }).catch((error) => {
            resolve(error.data)
          })
        })
      }
    },

    submitCheck: {
      url: `${config.API_URL}/accountrecordss/commitAudit`,
      name: "提交客户联系记录审核",
      post: function (data) {
        return new Promise((resolve, reject) => {
          http.postParam(this.url, data).then((response) => {
            resolve(response)
          }).catch((error) => {
            resolve(error.data)
          })
        })
      }
    },

    checkRecord: {
      url: `${config.API_URL}/accountrecordss/audit`,
      name: "审核客户联系记录",
      post: function (data) {
        return new Promise((resolve, reject) => {
          http.postParam(this.url, data).then((response) => {
            resolve(response)
          }).catch((error) => {
            resolve(error.data)
          })
        })
      }
    },

    getProjectById: {
      url: `${config.API_URL}/accountrecordss/select`,
      name: "根据客户ID获取项目",
      post: function (data) {
        return new Promise((resolve, reject) => {
          http.postParam(this.url, data).then((response) => {
            resolve(response)
          }).catch((error) => {
            resolve(error.data)
          })
        })
      }
    },

    getCustomerById: {
      url: `${config.API_URL}/customer/viewListByAdminId`,
      name: "获取当前用户下的客户",
      post: function (data) {
        return new Promise((resolve, reject) => {
          http.post(this.url, data).then((response) => {
            resolve(response)
          }).catch((error) => {
            resolve(error.data)
          })
        })
      }
    },
  },

  getDealRecords: {
    url: `${config.API_URL}/customer/customerNumberByYearMonth`,
    name: "获取客户成交记录",
    get: function (data) {
      return new Promise((resolve, reject) => {
        http.get(this.url, data).then((response) => {
          resolve(response)
        }).catch((error) => {
          resolve(error.data)
        })
      })
    }
  },

  getCustomerConaults: {
    url: `${config.API_URL}/customerQuotes/list`,
    name: "获取客户咨询列表",//官网客户提交咨询
    get: function (data) {
      return new Promise((resolve, reject) => {
        http.get(this.url, data).then((response) => {
          resolve(response)
        }).catch((error) => {
          resolve(error.data)
        })
      })
    }
  },

  // 公共客户
  publicCustomer: {
    getCustomerList: {
      url: `${config.API_URL}/customer/communalList`,
      name: "获取客户列表",
      get: function (param) {
        return new Promise((resolve, reject) => {
          http.get(this.url, param).then((response) => {
            resolve(response)
          }).catch((error) => {
            resolve(error.data)
          })
        })
      }
    },
    bindCustomer: {
      url: `${config.API_URL}/customer/contend`,
      name: "绑定客户",
      post: function (param) {
        return new Promise((resolve, reject) => {
          http.postParam(this.url, param).then((response) => {
            resolve(response)
          }).catch((error) => {
            resolve(error.data)
          })
        })
      }
    },
  }

}
